package l1j.server.server.model.damage.physical;

import l1j.server.server.ActionCodes;
import l1j.server.server.model.Instance.L1NpcInstance;
import l1j.server.server.model.damage.L1DamageOnNpc;
import l1j.server.server.model.damage.L1Dmg;
import l1j.server.server.model.damage.L1NpcDamage;
import l1j.server.server.serverpackets.S_DoActionGFX;

public class L1PhysicalDamage_Npc_Npc extends L1Dmg {

	private L1NpcInstance _attacker;

	private L1NpcInstance _target;

	private L1NpcDamage _npcDamage;

	public L1PhysicalDamage_Npc_Npc(L1NpcInstance attacker, L1NpcInstance target) {
		_attacker = attacker;
		_target = target;
		_npcDamage = new L1NpcDamage(attacker, target, this);
	}

	@Override
	public void calcDmg() {
		_npcDamage.calcNpcDmg();
		L1DamageOnNpc dop = new L1DamageOnNpc(this, _target);
		dop.calcDamageOnNpc();
		_npcDamage.isWeaponBreaked();
		_npcDamage.addNpcPoisonAttack();
	}

	@Override
	public void hurtTarget(boolean actionHurt) {
		commitAttacker(_attacker);
		commitTarget(_target);
		_target.receiveDamage(_attacker, getValue());
		if (getValue() > 0 && actionHurt) {
			_target.broadcastPacket(new S_DoActionGFX(_target.getId(),
					ActionCodes.ACTION_Damage));
		}
	}

}
